import { Request } from "express";

export function getClientIp(req: Request): string {
    const forwarded = req.headers["x-forwarded-for"];
    return typeof forwarded === "string"
        ? forwarded.split(",")[0]
        : req.socket.remoteAddress || "0.0.0.0";
}
